package com.beagle.njddapp.ui.activity.oil;

import android.app.DatePickerDialog;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.beagle.njddapp.R;
import com.beagle.njddapp.base.BaseMvpActivity;
import com.beagle.njddapp.bean.UploadBean;
import com.beagle.njddapp.bean.oil.OilBean;
import com.beagle.njddapp.ui.presenter.OilAddPresenter;
import com.beagle.njddapp.ui.view.OilAddView;
import com.beagle.njddapp.utils.GlideEngine;
import com.beagle.njddapp.utils.StatusBarUtil;
import com.blankj.utilcode.util.ToastUtils;
import com.bumptech.glide.Glide;
import com.zhihu.matisse.Matisse;
import com.zhihu.matisse.MimeType;
import com.zhihu.matisse.internal.entity.CaptureStrategy;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author hxx
 * @date 2021-03-25 15:14
 */
public class OilUpdateActivity extends BaseMvpActivity<OilAddView, OilAddPresenter> implements OilAddView, View.OnClickListener {

    @BindView(R.id.commom_title_tv)
    TextView tvTitle;
    @BindView(R.id.common_container)
    RelativeLayout container;
    @BindView(R.id.common_tv_right)
    TextView tvRight;
    @BindView(R.id.oil_iv)
    ImageView iv;
    @BindView(R.id.ed_number)
    TextView edNUmber;
    @BindView(R.id.ed_changjia)
    TextView edChangJia;
    @BindView(R.id.ed_mingpai)
    TextView edMingPai;
    @BindView(R.id.ed_count)
    TextView edCount;
    @BindView(R.id.tv_time)
    TextView tvTIme;
    private OilBean data;



    @Override
    public int getLayoutId() {
        return R.layout.activity_updateoil;
    }

    @Override
    public void init() {
        StatusBarUtil.setPaddingSmart(this,container);
        container.setBackgroundColor(Color.WHITE);
        StatusBarUtil.darkMode(this);
        tvTitle.setText("加油车详情");
        data= (OilBean) getIntent().getSerializableExtra("data");
        if (data==null){
            finish();
            return;
        }
        tvRight.setText("修改");
        edNUmber.setText(data.getCarNum());
        edChangJia.setText(data.getProductionFactory());
        edCount.setText(data.getOilMeter()+"");
        edMingPai.setText(data.getEngineNum());
        tvTIme.setText(data.getProductionDate());
        Glide.with(this).load(data.getPictureUrl()).into(iv);

    }


    @OnClick({R.id.common_tv_right,R.id.common_back_iv})
    public void onMyClick(View view){
        switch (view.getId()){
            case R.id.common_back_iv:
                onBackPressed();
                break;
            case R.id.common_tv_right:
                startActivity(new Intent(this,OilAddActivity.class).putExtra("data",data));
                finish();
                break;
        }
    }

    @Override
    public OilAddView getMvpView() {
        return this;
    }

    @Override
    public OilAddPresenter createPresenter() {
        return new OilAddPresenter();
    }

    @Override
    public void onError(String message) {
        ToastUtils.showShort(message);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

    }


    @Override
    public void showSuccess() {
        ToastUtils.showShort("修改成功");
        setResult(303);
        finish();
    }

    @Override
    public void UploadSuccess(UploadBean data) {

    }

    @Override
    public void onClick(View view) {

    }
}
